﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Customer_Profile.eCardReport.DBDao;
using KVB.Common;
using System.Text;
using Customer_Profile.eCard.DBDao;

namespace Customer_Profile.eCardReport
{
    public partial class Value_byProd_Report : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!Page.IsPostBack)
            {                
                txtgedatebegin.Text = DateTime.Now.ToString("yyyy-MM-01");
                DateTime dt = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01")).AddMonths(1).AddDays(-1);
                txtgedateend.Text = dt.ToString("yyyy-MM-dd");
            }
            BindDataView();
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {

        }

        private void BindDataView()
        {
            string startDate = txtgedatebegin.Text;
            string endDate = txtgedateend.Text;
            try
            {
                DataSet dsResult = ReportDao.ValuebyProdReprot(startDate,endDate);
                if (dsResult != null && dsResult.Tables.Count > 0)
                {                    
                    ASPxGridView1.DataSource = dsResult.Tables[0];
                    ASPxGridView1.DataBind();                 
                }                
            }
            catch (Exception ex)
            {
                Log.WriteDefaultLog("eCardReport.Value_byProd_Report", ex.ToString());
            }
        }

        protected void btnExport_Click(object sender, EventArgs e)
        {
            ASPxGridViewExporter1.WriteXlsToResponse();
        }
    }
}